package com.yuezhu.util;

import android.util.Log;

/**
 * @创建人：zhaoshuzhen
 * @创建时间：2015/12/8 10:10
 * 登录状态类
 */
public class LogUtils {
	public static final String TAG = "ok_log";
	public static final boolean RENDER_LOG = false;
	public static final boolean IS_LOG = true;

	public static void d(String key, String value) {
		if (IS_LOG) {
			Log.d(key, value);
		}
	}

	public static void d(String value) {
		if (IS_LOG) {
			log(Log.DEBUG, value, null);
		}
	}

	public static void i(String key, String value) {
		if (IS_LOG) {
			Log.i(key, value);
		}
	}

	public static void e(String key, String value) {
		if (IS_LOG) {
			Log.e(key, value);
		}
	}

	public static void renderDebug(String key, String logMsg) {
		if(IS_LOG && RENDER_LOG) {

			Log.e(key, logMsg);
		}
	}

	public static void e(Throwable throwable) {
		e(throwable, throwable.getMessage());
	}

	private static void log(int priority, String msg, Throwable throwable) {
		if (!IS_LOG)
			return;

		try {
			Log.println(
					priority,
					"damai",
					msg
							+ (throwable == null ? "" : Log
									.getStackTraceString(throwable)));
		} catch (Exception e) {
			Log.e("damai", "Failed to log: " + e.getMessage());
		}
	}

	public static void e(Throwable throwable, String error) {
		if (!IS_LOG)
			return;

		try {
			log(Log.ERROR, error, throwable);
		} catch (Exception e) {
			Log.e("damai", "Failed to e: " + e.getMessage());
		}
	}

	public static void e(String error){
		if(IS_LOG){
			Log.e(TAG, error.toString());
		}
	}


	public static boolean isLoggable(String var0, int var1){
		return Log.isLoggable(var0,var1);
	}

}